package com.impzx.restaurant.rest;

import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.PathSegment;

import com.impzx.restaurant.rest.dataobject.DemoObject;
/**
 * rest服务的get请求的简单Demo
 * 主要功能有:
 * 		1、简单的get获取请求，获取字符串
 * 		2、简单的get获取请求，获取对象
 * 		3、 简单的get删除信息
 * @author zhenxuan.panzx
 */

@Path("/simpleGet")
public class SimpleGetDemo {
	
	@GET
	@Path("/getInfoStr")
	public String getInfoStr(String param) {
		String result = "info";
		return result;
	}
	
	@GET
	@Path("/getInfoObjJson")
	public String getInfoObjJson(String param) {
		return "";
	}
	
	@GET
	@Path("/books/{isbn}")
	public String getBookIsbn(@PathParam("isbn") String isbn) {
		return "book isbn is " + isbn;
	}
	
	@GET
	@Path("/{info}")
	public String getObject(@PathParam("info") DemoObject info) {
		return "id is " + info.getId() + "  name is " + info.getName();
	}
	
	@GET
	@Path("/book/{id}")
	public String getBook(@PathParam("id") PathSegment id) {
		String s = "";
		System.out.println(id.getPath());
		Map<String, List<String>> map = id.getMatrixParameters();
		for(Entry entry : map.entrySet()) {
			System.out.println(entry.getKey());
			System.out.println(entry.getValue());
		}	
		return s;
	}
	
	@PUT
	public String getBooks(@HeaderParam("Content-Type") MediaType contentType) {
		System.out.println(contentType==null);
		return "from";
	}
}
